﻿#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include "hidapi.h"
#include <QTimer>
#include <QThread>


namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT
    QThread m_thread;
public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

private slots:

    void on_openBtn_clicked();

    void on_sendBtn_clicked();

    void on_clearSendBtn_clicked();

    void on_clearRecvBtn_clicked();

public slots:
     void handleResults(const QByteArray &);

signals:
     void operate();
private:
    Ui::MainWindow *ui;
    bool m_isOpen = false;
    hid_device *m_handle  = nullptr;
};

extern hid_device *g_device;
extern bool g_isRecv;
class ReadUSB : public QObject
{
    Q_OBJECT

public slots:
    void readData();
signals:
    void resultReady(const QByteArray &result);
};
#endif // MAINWINDOW_H
